package com.huiruan.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.huiruan.dto.OrderCreateDTO;
import com.huiruan.entity.Order;
import com.huiruan.entity.TStock;
import com.huiruan.service.OrderService;
import com.huiruan.utils.Result;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.data.redis.connection.SortParameters;
import org.springframework.web.bind.annotation.*;

/**
 * @author CTL
 * @create 2025-05-13 16:53
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/order")
public class OrderController {
    private final OrderService orderService;


    @Operation(summary = "分页查询", description = "返回所有订单数据")
    @GetMapping("/page" )
    public Result getPage(Page page, Order order) {
        return Result.success(orderService.page(page, Wrappers.query(order)));
    }


    /**
     * 订单列表
     *
     * @return
     */
    @GetMapping("/list")
    public Result getList() {
        return Result.success();
    }
    /**
     * 创建订单
     *
     * @return
     */
    @PostMapping("/create")
    public Result createOrder(@RequestBody OrderCreateDTO orderCreateDTO) {
        return Result.success("创建成功");
    }
    /**
     * 获取订单详情
     *
     * @param id
     * @return
     */
    @GetMapping("/detail/{id}")
    public Result getDetail(@PathVariable Long id) {
        return Result.success();
    }

    /**
     * 取消订单
     *
     * @param id
     * @return
     */
    @PutMapping("/cancel/{id}")
    public Result cancelOrder(@PathVariable Long id) {
        return Result.success();
    }

    /**
     * 确认收货
     * @return
     */
    @PutMapping("/confirm/{id}")
    public Result confirmOrder(@PathVariable Long id) {
        return Result.success();

    }

    /**
     * 删除订单
     * @return
     */
    @DeleteMapping("/delete/{id}")
    public Result deleteOrder(@PathVariable Long id){
        return  Result.success();
    }

    /**
     * 支付订单
     * @return
     */
    @PostMapping("/pay/{id}")
    public  Result payOrder(@PathVariable Long id){
        return  Result.success();
    }
}
